<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>高阶函数</title>
</head>

<body>
    <script>
        //高阶函数：以函数作为参数或者以函数作为返回值的函数。

        //btn.onclick=function(){}

        //1.
        //  var fn=function(){
        //       console.log('hello');
        //  }  
        function fn() {
            console.log('hello');
        }

        function show(a, b, fn) {
            fn();
        }
        show(10, 20, fn);

        //2.
        function show1(a, b) {
            var fn1 = function () {
                console.log('good');
            }
            return fn1;
        }

        var fn1 = show1(10, 20);
        fn1();

        //3.

        //   setInterval(回调函数,1000);
        setInterval(function () { }, 1000);
        function callback() {
            console.log('nice');
        }

        setInterval(callback, 1000)

        setInterval("callback()", 1000)
    </script>
</body>

</html>